package com.bltec.emergency.mapper;


import com.bltec.emergency.model.ForeignBase;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface ForeignBaseMapper {
    //插入一条foreignBase记录
    @Insert("insert into foreign_base (search_area,occurred_time,details," +
            "create_by,create_time,enable) " +
            "values(#{searchArea},#{occurredTime},#{details},#{createBy},#{createTime},#{enable})")
    boolean insert(ForeignBase foreignBase);

    //通过id设置一条记录为不可用
    @Update("update foreign_base set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update foreign_base set search_area=#{searchArea},occurred_time=#{occurredTime},details=#{details}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateForeignBaseById(ForeignBase foreignBase);

    //查找符合id字段的记录
    @Select("select id,search_area,occurred_time,details," +
            "create_by,create_time,update_by,update_time,enable" +
            " from foreign_base where id =#{id} and enable=1")
    ForeignBase getForeignBaseById(Long id);

    //查找所有记录
    @Select("select id,search_area,occurred_time,details," +
            "create_by,create_time,update_by,update_time,enable" +
            " from foreign_base where enable=1")
    List<ForeignBase> selectAll();
}